package web.demo.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import web.demo.entity.FoodTable;
import web.demo.entity.Orders;
import web.demo.factory.BeanFactory;
import web.demo.service.impl.FoodTableService;
import web.demo.service.impl.OrdersService;

public class IndexServlet extends HttpServlet {

	private FoodTableService foodTableService=BeanFactory.getInstance("foodTableService",FoodTableService.class);
	private OrdersService ordersService=BeanFactory.getInstance("ordersService",OrdersService.class);
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//得到所有空闲的餐桌	0 空闲 1 预定
		List<FoodTable> list=foodTableService.getAll(0);
		//将餐桌列表显示在页面上
		request.setAttribute("foodTableList",list);
		//跳转
		RequestDispatcher rd=request.getRequestDispatcher("app/index.jsp");
		rd.forward(request,response);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
}
